package com.ssh.api.action;

import java.util.List;

import javax.annotation.Resource;

import org.apache.struts2.convention.annotation.ParentPackage;
import org.apache.struts2.convention.annotation.Result;
import org.apache.struts2.convention.annotation.Results;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;

import com.opensymphony.xwork2.ActionSupport;
import com.ssh.common.log.LogFactory;
import com.ssh.common.log.LogName;
import com.ssh.common.util.JsonResult;
import com.ssh.entity.Brand;
import com.ssh.entity.Company;
import com.ssh.entity.SuperMarket;
import com.ssh.manager.TaskProductEmployeeManager;

@Controller
@ParentPackage("client")
@Scope("prototype")
@Results(value={@Result(name ="copmayList",type="json",params={"root","jr","excludeProperties","data\\[\\d+\\]\\.content,data\\[\\d+\\]\\.del,data\\[\\d+\\]\\.createDate"})
,@Result(name ="superMarketList",type="json",params={"root","jr","includeProperties","data\\[\\d+\\]\\.id,data\\[\\d+\\]\\.name,code,message,method","excludeNullProperties","true"})
,@Result(name ="brandList",type="json",params={"root","jr","excludeNullProperties","true"})
})
public class EnumerateClientAction extends ActionSupport {
	private static final long serialVersionUID = 3722877383490158563L;
   
	JsonResult jr=new JsonResult();
	Long employeeId;
	Long taskId;
    Long companyId;
    Long superMarketId;

    @Resource(name="taskProductEmployeeManagerImpl")
	private TaskProductEmployeeManager taskProductEmployeeManagerImpl;
	

	
	public  String copmayList(){
		jr.setMethod("copmayList");
		try{
	    	jr.setCode("0");
	    	List<Company> listresult=taskProductEmployeeManagerImpl.companyListFromTask(taskId, employeeId);
	    	jr.setData(listresult);
		}catch (Exception e) {
			jr.setCode("-1");
			jr.setMessage(e.getMessage());
			LogFactory.getDefaultLog().error("查询失败", LogName.API);
		}
		return "copmayList";
    }
	
	
	public  String superMarketList(){
		jr.setMethod("superMarketList");
		try{
	    	jr.setCode("0");
	    	List<SuperMarket> listresult=taskProductEmployeeManagerImpl.superMarketListFromTaskAndCompany(taskId, companyId, employeeId);
	    	jr.setData(listresult);
		}catch (Exception e) {
			jr.setCode("-1");
			jr.setMessage(e.getMessage());
			LogFactory.getDefaultLog().error("查询失败", LogName.API);
		}
		return "superMarketList";
    }
	
	
	public  String brandList(){
		jr.setMethod("brandList");
		try{
	    	jr.setCode("0");
	    	List<Brand> listresult=taskProductEmployeeManagerImpl.branListFromTaskAndCompany(taskId, superMarketId, employeeId);
	    	jr.setData(listresult);
		}catch (Exception e) {
			jr.setCode("-1");
			jr.setMessage(e.getMessage());
			LogFactory.getDefaultLog().error("查询失败", LogName.API);
		}
		return "brandList";
    }

	public JsonResult getJr() {
		return jr;
	}

	public void setJr(JsonResult jr) {
		this.jr = jr;
	}


	public Long getEmployeeId() {
		return employeeId;
	}


	public void setEmployeeId(Long employeeId) {
		this.employeeId = employeeId;
	}


	public Long getTaskId() {
		return taskId;
	}


	public void setTaskId(Long taskId) {
		this.taskId = taskId;
	}


	public Long getCompanyId() {
		return companyId;
	}


	public void setCompanyId(Long companyId) {
		this.companyId = companyId;
	}


	public Long getSuperMarketId() {
		return superMarketId;
	}


	public void setSuperMarketId(Long superMarketId) {
		this.superMarketId = superMarketId;
	}


	
}
